package com.cmcc.groupcontacts.firewall.activity;

import android.app.TabActivity;
import android.content.SharedPreferences;
import android.content.res.ColorStateList;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.Display;
import android.view.LayoutInflater;
import android.view.View;

import com.cmcc.groupcontacts.MainApp;
import com.cmcc.groupcontacts.util.ActivityHelper;
import com.cmcc.groupcontacts.util.DisplayMetricsConverter;

/**
 * TabActivity抽象基类
 * 
 * @author 
 * 
 */
public abstract class BaseTabActivity extends TabActivity {
	private ActivityHelper helper = new ActivityHelper(this);

	private View tabWidgetView;
	private View tabContentView;

	protected DisplayMetricsConverter getDmConverter() {
		return MainApp.getDmConverter();
	}

	protected SharedPreferences getPreference() {
		return MainApp.getPreference();
	}

	public LayoutInflater getInflater() {
		return helper.getInflater();
	}

	public Display getDisplay() {
		return helper.getDisplay();
	}

	public Drawable getDrawable(int drawableId) {
		return getResources().getDrawable(drawableId);
	}

	public int getColor(int colorId) {
		return getResources().getColor(colorId);
	}

	public ColorStateList getColorStateList(int colorStateListId) {
		return getResources().getColorStateList(colorStateListId);
	}

	/**
	 * 获取Tab标签视图
	 * 
	 * @return
	 */
	public View getTabWidgetView() {
		if (tabWidgetView == null) {
			tabWidgetView = findViewById(android.R.id.tabs);
		}
		return tabWidgetView;
	}

	/**
	 * 获取Tab内容视图
	 * 
	 * @return
	 */
	public View getTabContentView() {
		if (tabContentView == null) {
			tabContentView = findViewById(android.R.id.tabcontent);
		}
		return tabContentView;
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
	}

	@Override
	protected void onStart() {
		super.onStart();
	}

	@Override
	protected void onDestroy() {
		super.onDestroy();
	}

	@Override
	protected void onResume() {
		super.onResume();
		try {
			// MobclickAgent.onResume(this);
		} catch (Exception e) {
		}
	}

	@Override
	protected void onPause() {
		super.onPause();
		try {
			// MobclickAgent.onPause(this);
		} catch (Exception e) {
		}
	}
}
